package com.example.demo.controller;

import com.example.demo.entity.UploadProperties;
import com.example.demo.service.UploadFile;
import com.example.demo.service.impl.UploadFileQiniu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 上传到七牛云
 */
@RestController
@RequestMapping("/upload")
public class UploadFileController {
    @Autowired
    UploadProperties uploadProperties;

    @PostMapping("/img")
    public String uploadFileYun(MultipartFile file) throws Exception {
        // 上传到七牛云
//        SslUtil.ignoreSsl();
        UploadFile uploadFile = new UploadFileQiniu(uploadProperties.getQiniu());
        return uploadFile.uploadFile(file);
    }
}